<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:template match="varlistentry/term">
        <xsl:element name="div">
            <xsl:attribute name="class">term</xsl:attribute>
            <xsl:call-template name="anchor" />
            <xsl:apply-templates />
            <xsl:choose>
                <xsl:when test="position() = last()" />
                <!-- do nothing -->
                <xsl:otherwise>
                    <!-- * if we have multiple terms in the same varlistentry, generate -->
                    <!-- * a separator (", " by default) and/or an additional line -->
                    <!-- * break after each one except the last -->
                    <xsl:value-of select="$variablelist.term.separator" />
                    <xsl:if test="not($variablelist.term.break.after = '0')">
                        <br />
                    </xsl:if>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:element>
    </xsl:template>

    <xsl:template match="varlistentry" mode="varlist-table">
        <xsl:variable name="presentation">
            <xsl:call-template name="dbhtml-attribute">
                <xsl:with-param name="pis" select="../processing-instruction('dbhtml')" />
                <xsl:with-param name="attribute" select="'term-presentation'" />
            </xsl:call-template>
        </xsl:variable>

        <xsl:variable name="separator">
            <xsl:call-template name="dbhtml-attribute">
                <xsl:with-param name="pis" select="../processing-instruction('dbhtml')" />
                <xsl:with-param name="attribute" select="'term-separator'" />
            </xsl:call-template>
        </xsl:variable>
        <tr>
            <xsl:call-template name="tr.attributes">
                <xsl:with-param name="rownum">
                    <xsl:number from="variablelist" count="varlistentry" />
                </xsl:with-param>
            </xsl:call-template>

            <td valign="top">
                <xsl:call-template name="anchor" />
                <xsl:choose>
                    <xsl:when test="$presentation = 'bold'">
                        <b>
                            <xsl:apply-templates select="term" />
                            <xsl:value-of select="$separator" />
                        </b>
                    </xsl:when>
                    <xsl:when test="$presentation = 'italic'">
                        <i>
                            <xsl:apply-templates select="term" />
                            <xsl:value-of select="$separator" />
                        </i>
                    </xsl:when>
                    <xsl:when test="$presentation = 'bold-italic'">
                        <b>
                            <i>
                                <xsl:apply-templates select="term" />
                                <xsl:value-of select="$separator" />
                            </i>
                        </b>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:apply-templates select="term" />
                        <xsl:value-of select="$separator" />
                    </xsl:otherwise>
                </xsl:choose>
            </td>
            <td valign="top">
                <xsl:apply-templates select="listitem" />
            </td>
        </tr>
    </xsl:template>


</xsl:stylesheet>
